package ProjectXXX;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.TitledBorder;
import java.sql.*;


public class ManagersArea extends JPanel implements ActionListener
{
	private JPanel basePanel = null,centerPanel = null,mainButPanel = null;
	
	private JButton reportBut = null,settingsBut = null;
	
	private BoxLayout myBoxLayout1 = null;
	private BoxLayout myBoxLayout2 = null;
	
	private JFrame testFrame = null;
	
	private int panelsAccess = 2;
	
	PrintReportPanel prp = null;
	AdvancedSettingsPanel ads = null;
	PasswordXXX p = null;
	Connection turtleConn = null;
	
	public ManagersArea(Connection inConn)
	{
		turtleConn = inConn;
		
		//create GUIS
		prp = new PrintReportPanel(turtleConn);
		ads = new AdvancedSettingsPanel(turtleConn);
		
		//mainButtonPanel
		reportBut = new JButton("Reports");
		//reportBut.setBorder(BorderFactory.createLineBorder(Color.black,1));
		reportBut.addActionListener(this);
		reportBut.setPreferredSize(new Dimension(Short.MAX_VALUE,30));
		settingsBut = new JButton("Advanced Settings");
		//settingsBut.setBorder(BorderFactory.createLineBorder(Color.black,1));
		settingsBut.addActionListener(this);
		settingsBut.setPreferredSize(new Dimension(Short.MAX_VALUE,30));
		mainButPanel = new JPanel(new GridLayout(0,2));
		myBoxLayout1 = new BoxLayout(mainButPanel,BoxLayout.X_AXIS);
		mainButPanel.setLayout(myBoxLayout1);
		mainButPanel.add(settingsBut);
		mainButPanel.add(reportBut);
		
		centerPanel = new JPanel(new GridLayout(1,1));
		centerPanel.add(ads);
		basePanel = new JPanel(new BorderLayout());
		basePanel.add(mainButPanel,BorderLayout.NORTH);
		basePanel.add(centerPanel);
		grayOut(settingsBut,reportBut);
		
		this.setLayout(new GridLayout(1,1));
		this.add(basePanel);
		
	}//end constructor
	
	public void actionPerformed(ActionEvent e)
	{
		Object source = e.getSource();
		if(source == reportBut)
		{
			grayOut(reportBut,settingsBut);
			centerPanel.removeAll();
			centerPanel.add(prp);
			this.validate();
			this.repaint();	
		}
		if(source == settingsBut)
		{
			grayOut(settingsBut,reportBut);
			centerPanel.removeAll();
			centerPanel.add(ads);
			this.validate();
			this.repaint();
		}
	}//end actionPerformed
	
	public int getPanelsAccess()
	{
		return panelsAccess;
	}
	public void setReportBut(boolean holder)
	{
		reportBut.setEnabled(holder);
	}
	public void grayOut(JButton but,JButton but2)
	{
		but2.setBackground(but.getBackground());
		but.setBackground(Color.LIGHT_GRAY);
	}	
}//end class declaration